package com.ce.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ce.server.common.RespPageBean;
import com.ce.server.pojo.Operlog;
import com.ce.server.mapper.OperlogMapper;
import com.ce.server.service.IOperlogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 郑爽
 * @since 2021-11-28
 */
@Service
public class OperlogServiceImpl extends ServiceImpl<OperlogMapper, Operlog> implements IOperlogService {

  @Autowired
  private OperlogMapper operlogMapper;

  @Override
  public RespPageBean getRecordByPage(Integer currentPage, Integer size) {
    Page<Operlog> page = new Page<>(currentPage, size);
    IPage<Operlog>  operlogIPage = operlogMapper.getRecordByPage(page);
    if (operlogIPage!=null)
      return new RespPageBean(operlogIPage.getTotal(),operlogIPage.getRecords());
    return new RespPageBean(0L,null);
  }
}
